<template>
	<view class="myHelpDel">
		<view class="header">
			<text class="h_title">{{ dataInfo.diseaseName || '暂无该疾病' }}</text>
			<text>发布者：{{ dataInfo.ownerUserName || this.$storage.getItem('roleDataInfo').name }}</text>
		</view>
		<view class="main">
			<view class="m_list">
				<text class="m_title">【患者基本信息】：</text>
				<view class="m_message">
					<text class="handLetterSpa">姓名：{{ dataInfo.name }}</text>
					<text class="handLetterSpa">性别：{{ dataInfo.gender==0? '保密' : dataInfo.gender==1? '男' : '女' }}</text>
					<text class="handLetterSpa">籍贯：{{ dataInfo.address }}</text>
				</view>
			</view>
			<view class="m_list">
				<view class="m_module">
					<text class="m_title">【详细情况(患病过程、治疗经历、目前状况)】：</text>
					<view class="m_con handLetterSpa">
						<text>{{ dataInfo.details || '---' }}</text>
					</view>
				</view>
				<view class="m_module" v-if="dataInfo.fileIdListName.length">
					<text class="m_title">【附件(相关照片、检查、医院诊断书)】：</text>
					<view class="m_con handLetterSpa">
						<view class="fileImage">
							<image @click="getBigImg(el)" v-for="(el, index) in dataInfo.fileIdListName" :key="index" :src="el"></image>
						</view>
					</view>
				</view>
			</view>
			<view class="answer m_list" v-if="dataInfo.replyContent">
				<text class="m_title">【医生答复】：</text>
				<view class="handLetterSpa m_con">{{ dataInfo.replyContent }}</view>
			</view>
		</view>
		<showImg
			:show="comInfo.showBigImg"
			:src="comInfo.src"
			@close="close"
		/>
		<van-toast id='van-toast'/>
	</view>
</template>

<script>
	import { seekHelpGetById, seekHelpReply } from '@/api/my'
	import { fileById } from '@/api/common'
	import showImg from '@/components/showBigImg'
	export default {
		name: 'myHelpDel',
		components: { showImg },
		data() {
			return {
				dataInfo: {},
				comInfo: {
					showBigImg: false,
					src: ''
				}
			}
		},
		onLoad(option) {
			this.getDataInfo(option);
		},
		methods: {
			getDataInfo(val) {
				seekHelpGetById({ id: val.id }).then(res => {
					this.dataInfo = res.data;
					if (res.data.fileIdList.length) {
						this.getFile(res.data.fileIdList,'fileIdListName')
					}
					this.$set(this.dataInfo, 'diseaseName', val.diseaseName);
					if (res.data.replyContent) {
						this.getReply(res.data.id)
					}
				})
			},
			getFile(val,typeName) {
				let arr = [];
				val.map(item => {
				  fileById({ fileId: item }).then(res => {
						if (res.data && res.data.accessUrl) {
							arr.push(res.data.accessUrl)
						}
					})
				})
				this.$set(this.dataInfo,typeName, arr);
			},
			getReply(id) {
				seekHelpReply({ helpId: id }).then(res => {
					console.log(res)
				})
			},
			getBigImg(el) {
				this.comInfo.showBigImg = true;
				this.comInfo.src = el;
			},
			close(val) {
				this.comInfo.showBigImg = val;
			}
		}
	}
</script>

<style lang="scss" scoped>
	.myHelpDel {
		width: 100%;
		position: relative;
		padding: 0 20rpx 60rpx;
		box-sizing: border-box;
		.header {
			padding: 0 15% 40rpx;
			text {
				display: block;
				width: 100%;
				text-align: right;
				font-size: 28rpx;
			}
			.h_title {
				padding-bottom: 20rpx;
				font-size: 40rpx;
				text-align: center;
				font-weight: 600;
			}
		}
		.main {
			width: 100%;
			.answer {
				margin-top: 16rpx;
				border: 1px solid #ccc;
			}
		}
	}
</style>
